package websocket

import (
	"fmt"
	"im/im-cloud/app/data"
	ser "im/server/websocket"
)


// 注册方法
func Register(server *ser.Server, receive *data.Receive) {
	redisc, err := data.GetRedisC()
	if err != nil {
		server.Send("{\"code\": 500, \"msg\":\"im-cloud的redis连接异常\"}")
		return // 结束
	}
	fmt.Println(receive.Addr)
	_, err = redisc.Do("sadd", data.ServerKey, receive.Addr)
	if err != nil {
		server.Send("{\"code\": 500, \"msg\":\"im-server注册失败 异常信息" + err.Error() + "\"}")
	}else {
		server.Send("{\"code\": 200, \"msg\":\"im-server注册成功\"}")
	}
}
